package com.example.project_springboot.controller;

import com.example.project_springboot.aop.Log;
import com.example.project_springboot.pojo.Result;
import com.example.project_springboot.pojo.Users;
import com.example.project_springboot.service.UsersService;
import com.example.project_springboot.utils.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class UsersController {
    @Autowired
    UsersService usersService;

    @PostMapping("/loginAi")
    @Log
    public Result loginAi(@RequestBody Users users) {
        Users use = usersService.loginOfUsers(users);
        if (use != null) {
            HashMap<String, Object> map = new HashMap<>();
            map.put("老王", 1);
            String s = JwtUtils.generateJwt(map);
            System.out.println(s);
            return Result.success(s);
        }
        return Result.success("输入有误");
    }
}
